<template>
    <div class="body paystatus">
        <div>订单支付确认中，请勿切换页面</div>
        <img src="../img/timg.gif" alt="">
    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
    export default {
        name: "paystatus",
        data(){
            return {

            }
        },
        mounted(){
            this.getuserinfo();
            document.querySelector('html').setAttribute('style', 'overflow:auto');
            document.querySelector('body').setAttribute('style', 'overflow:auto');
            document.querySelector('#app').setAttribute('style', 'overflow:auto');
        },
        methods:{
            getuserinfo(){
                this.axios({
                    method: 'get',
                    url: 'apis/partner/userinfo',
                    data: {},
                    withCredentials: true,
                    headers: {'token':JSON.parse(localStorage.hhrdata).token},
                }).then((response) => {
                    console.log(response)
                    if(response.data.code==-8){
                        this.common.checkLogin(this);
                    }
                    if(response.data.code==0){
                        if(response.data.data.level!=JSON.parse(localStorage.hhrdata).level){
                            sessionStorage.removeItem("idrefresh");
                            // location.href = "http://"+window.location.host+"/#/perSon"
                            //this.$router.push({path: '/perSon', query: {ifresh: true}})
                            if (this.common.checkWechart()) {
                                Toast({
                                    message: "订单支付成功，2s后页面关闭，请重新进入应用",
                                    position: 'center',
                                    duration: 2000
                                });
                                let userAgent = navigator.userAgent;
                                if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") !=-1) {
                                    window.open('','_self').close()
                                    window.location.href = "about:blank"
                                }else {
                                    window.opener = null;
                                    window.open("about:blank", "_self");
                                    window.close();
                                }
                            }else{
                                this.$router.push({path: '/perSon', query: {ifresh: true}})
                            }
                        }else{
                            setTimeout(()=>{
                                this.getuserinfo();
                            },3000);
                        }
                    }
                }).catch((error) => {
                    console.log(error)
                });
            },
        }
    }
</script>

<style scoped lang="less">
    .paystatus{
        background: #fff;
        text-align: center;
        font-size: 0.4rem;
        vertical-align: middle;
        padding-top: 3rem;
        img{
            width:3rem;
        }
    }
</style>
